/**
 * 监听用户是否在操作，超过一定时间则进行提醒
 */
let idleTime = 0;
let idleInterval = 60;
let idleThreshold = 300;

function resetIdleTimer() {
  idleTime = 0;
}

document.addEventListener('mmousemove', resetIdleTimer);
document.addEventListener('click', resetIdleTimer);
document.addEventListener('wheel', resetIdleTimer);
document.addEventListener('scroll', resetIdleTimer);
document.addEventListener('keypress', resetIdleTimer);

seltInterval = setInterval(() => {
  idleTime += idleInterval;
  if (idleTime >= idleThreshold) {
    console.log('空闲时间:', idleTime + '秒');
  }
}, idleInterval * 1000);

/**
 * 基础禁止调试代码
 */
(() => {
  function block() {
    if (
      window.outerHeight - window.innerHeight > 200 ||
      window.outerWidth - window.innerWidth > 200
    ) {
      document.body.innerHTML =
        "<div style='color:red;width:100%;text-align:center;height:100%;line-height:200px'>检测到非法调试,请关闭后刷新重试!</div>";
    }
    setInterval(() => {
      (function () {
        return false;
      })
        ['constructor']('debugger')
        ['call']();
    }, 50);
  }
  try {
    if (window.localStorage.getItem('ignore_debug') == 1) {
      return;
    }
    block();
  } catch (err) {}
})();
